home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / gnome-games / aisleriot / games / auld_lang_syne.scm < prev    next >
Encoding:
Text File  |  2009-04-14  |  3.8 KB  |  144 lines

  1. ; AisleRiot - auld_lang_syne.scm
  2. ; Copyright (C) 1999, 2003 Rosanna Yuen <rwsy@mit.edu>
  3. ;
  4. ; This game is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2, or (at your option)
  7. ; any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  17. ; USA
  18.  
  19. (define (new-game)
  20.   (initialize-playing-area)
  21.   (set-ace-low)
  22.   (set! DECK (make-deck-list-ace-low 2 2 club))
  23.   (shuffle-deck)
  24.  
  25.   (add-normal-slot DECK)
  26.   (add-blank-slot)
  27.   (add-normal-slot '())
  28.   (add-normal-slot '())
  29.   (add-normal-slot '())
  30.   (add-normal-slot '())
  31.   (add-carriage-return-slot)
  32.   (add-blank-slot)
  33.   (add-blank-slot)
  34.   (add-normal-slot '())
  35.   (add-normal-slot '())
  36.   (add-normal-slot '())
  37.   (add-normal-slot '())
  38.   
  39.   (add-card! 1 (make-visible (make-card ace club)))
  40.   (add-card! 2 (make-visible (make-card ace diamond)))
  41.   (add-card! 3 (make-visible (make-card ace heart)))
  42.   (add-card! 4 (make-visible (make-card ace spade)))
  43.  
  44.   (give-status-message)
  45.  
  46.   (list 6 2)
  47. )
  48.  
  49. (define (give-status-message)
  50.   (set-statusbar-message (get-stock-no-string)))
  51.  
  52. (define (get-stock-no-string)
  53.   (string-append (_"Stock left:") " "
  54.          (number->string (length (get-cards 0)))))
  55.  
  56. (define (button-pressed slot-id card-list)
  57.   (and (not (empty-slot? slot-id))
  58.        (> slot-id 4)))
  59.  
  60. (define (droppable? start-slot card-list end-slot)
  61.   (and (< end-slot 5)
  62.        (> end-slot 0)
  63.        (= (get-value (car card-list))
  64.           (+ 1 (get-value (get-top-card end-slot))))))
  65.  
  66. (define (button-released start-slot card-list end-slot)
  67.   (and (droppable? start-slot card-list end-slot)
  68.        (move-n-cards! start-slot end-slot card-list)
  69.        (add-to-score! 1)))
  70.  
  71. (define (dealable?)
  72.   (not (empty-slot? 0)))
  73.  
  74. (define (do-deal-next-cards)
  75.   (deal-cards-face-up 0 '(5 6 7 8)))
  76.  
  77. (define (button-clicked slot-id)
  78.   (and (= slot-id 0)
  79.        (not (empty-slot? 0))
  80.        (deal-cards-face-up 0 '(5 6 7 8))))
  81.  
  82. (define (check-end-slot? slot1 slot2)
  83.   (if (and (not (empty-slot? slot1))
  84.        (= (get-value (get-top-card slot1))
  85.           (+ 1 (get-value (get-top-card slot2)))))
  86.       (begin
  87.     (deal-cards slot1 (list slot2))
  88.     (add-to-score! 1))
  89.       (if (< slot2 4)
  90.       (check-end-slot? slot1 (+ 1 slot2))
  91.       #f)))
  92.  
  93. (define (button-double-clicked slot-id)
  94.   (and (> slot-id 4)
  95.        (check-end-slot? slot-id 1)))
  96.  
  97. (define (game-continuable)
  98.   (and (not (game-won))
  99.        (get-hint)))
  100.  
  101. (define (game-won)
  102.   (give-status-message)
  103.   (and (empty-slot? 0)
  104.        (empty-slot? 5)
  105.        (empty-slot? 6)
  106.        (empty-slot? 7)
  107.        (empty-slot? 8)))
  108.  
  109. (define (movable? slot1 slot2)
  110.   (if (= slot1 9)
  111.       #f
  112.       (if (or (= slot2 5)
  113.           (empty-slot? slot1))
  114.       (movable? (+ 1 slot1) 1)
  115.       (if (= (get-value (get-top-card slot1))
  116.          (+ 1 (get-value (get-top-card slot2))))
  117.           (list 1
  118.             (get-name (get-top-card slot1)) 
  119.             (get-name (get-top-card slot2)))
  120.           (movable? slot1 (+ 1 slot2))))))
  121.  
  122. (define (dealable?)
  123.   (and (not (empty-slot? 0))
  124.        (list 0 (_"Deal another round"))))
  125.  
  126. (define (get-hint)
  127.   (or (movable? 5 1)
  128.       (dealable?)))
  129.  
  130. (define (get-options) 
  131.   #f)
  132.  
  133. (define (apply-options options) 
  134.   #f)
  135.  
  136. (define (timeout) 
  137.   #f)
  138.  
  139. (set-features droppable-feature dealable-feature)
  140.  
  141. (set-lambda new-game button-pressed button-released button-clicked
  142. button-double-clicked game-continuable game-won get-hint get-options
  143. apply-options timeout droppable? dealable?)
  144.